home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / gdevxcmp.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  4.5 KB  |  149 lines

  1. /* Copyright (C) 1999 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: gdevxcmp.h,v 1.2 2000/09/19 19:00:23 lpd Exp $ */
  20. /* X driver color mapping structure */
  21.  
  22. #ifndef gdevxcmp_INCLUDED
  23. #  define gdevxcmp_INCLUDED
  24.  
  25. /*
  26.  * The structure defined in this file is used in only one place, in the
  27.  * gx_device_X structure defined in gdevx.h.  We define it as a separate
  28.  * structure because its function is logically separate from the rest of the
  29.  * X driver, and because this function (color mapping / management) accounts
  30.  * for the single largest piece of the driver.
  31.  */
  32.  
  33. /* Define pixel value to RGB mapping */
  34. typedef struct x11_rgb_s {
  35.     gx_color_value rgb[3];
  36.     bool defined;
  37. } x11_rgb_t;
  38.  
  39. /* Define dynamic color hash table structure */
  40. typedef struct x11_color_s x11_color_t;
  41. struct x11_color_s {
  42.     XColor color;
  43.     x11_color_t *next;
  44. };
  45.  
  46. /*
  47.  * Define X color values.  Fortuitously, these are the same as Ghostscript
  48.  * color values; in gdevxcmp.c, we are pretty sloppy about aliasing the
  49.  * two.
  50.  */
  51. typedef ushort X_color_value;
  52. #define X_max_color_value 0xffff
  53.  
  54. #if HaveStdCMap  /* Standard colormap stuff is only in X11R4 and later. */
  55.  
  56. /* Define the structure for values computed from a standard cmap component. */
  57. typedef struct x11_cmap_values_s {
  58.     int cv_shift;    /* 16 - log2(max_value + 1) */
  59.     X_color_value nearest[64]; /* [i] = i * 0xffff / max_value */
  60.     int pixel_shift;    /* log2(mult) */
  61. } x11_cmap_values_t;
  62.  
  63. #endif
  64.  
  65. typedef struct x11_cman_s {
  66.  
  67.     /*
  68.      * num_rgb is the number of possible R/G/B values, i.e.,
  69.      * 1 << the bits_per_rgb of the X visual.
  70.      */
  71.     int num_rgb;
  72.  
  73.     /*
  74.      * color_mask is a mask that selects the high-order N bits of an
  75.      * X color value, where N may be the mask width for TrueColor or
  76.      * StaticGray and is bits_per_rgb for the other visual classes.
  77.      *
  78.      * match_mask is the mask used for comparing colors.  It may have
  79.      * fewer bits than color_mask if the device is not using halftones.
  80.      */
  81.     struct cmm_ {
  82.     X_color_value red, green, blue;
  83.     } color_mask, match_mask;
  84.  
  85. #if HaveStdCMap  /* Standard colormap stuff is only in X11R4 and later. */
  86.  
  87.     struct {
  88.  
  89.     /*
  90.      * map is the X standard colormap for the display and screen,
  91.      * if one is available.
  92.      */
  93.     XStandardColormap *map;
  94.  
  95.     /*
  96.      * When possible, we precompute shift values and tables that replace
  97.      * some multiplies and divides.
  98.      */
  99.     bool fast;
  100.     x11_cmap_values_t red, green, blue;
  101.  
  102.     /*
  103.      * If free_map is true, we allocated the map ourselves (to
  104.      * represent a TrueColor or Static Gray visual), and must free it
  105.      * when closing the device.
  106.      */
  107.     bool free_map;
  108.  
  109.     } std_cmap;
  110.  
  111. #endif /* HaveStdCmap */
  112.  
  113.     /*
  114.      * color_to_rgb is a reverse map from pixel values to RGB values.  It
  115.      * only maps pixels values up to 255: pixel values above this must go
  116.      * through the standard colormap or query the server.
  117.      */
  118.     struct cmc_ {
  119.     int size;        /* min(1 << depth, 256) */
  120.     x11_rgb_t *values;    /* [color_to_rgb.size] */
  121.     } color_to_rgb;
  122.  
  123.     /*
  124.      * For systems with writable colormaps and no suitable standard
  125.      * colormap, dither_ramp is a preallocated ramp or cube used for
  126.      * dithering.
  127.      */
  128. #define CUBE_INDEX(r,g,b) (((r) * xdev->color_info.dither_colors + (g)) * \
  129.                   xdev->color_info.dither_colors + (b))
  130.     x_pixel *dither_ramp;    /* [color_info.dither_colors^3] if color,
  131.                    [color_info.dither_grays] if gray */
  132.  
  133.     /*
  134.      * For systems with writable colormaps, dynamic.colors is a chained
  135.      * hash table that maps RGB values (masked with color_mask) to
  136.      * pixel values.  Entries are added dynamically.
  137.      */
  138.     struct cmd_ {
  139.     int size;
  140.     x11_color_t **colors;    /* [size] */
  141.     int shift;        /* 16 - log2(size) */
  142.     int used;
  143.     int max_used;
  144.     } dynamic;
  145.  
  146. } x11_cman_t;
  147.  
  148. #endif /* gdevxcmp_INCLUDED */
  149.